package edu.mju.service.impl;

import edu.mju.dao.IRoutesDao;
import edu.mju.dao.impl.RoutesDaoImpl;
import edu.mju.entity.TouristRoutes;
import edu.mju.service.IRoutesService;
import edu.mju.util.EncryptUtil;
import edu.mju.util.Pager;
import edu.mju.util.StrUtil;

/**
 * @Author:wyp
 * @Date:2020/5/25 11:09
 */
public class RoutesServiceImpl implements IRoutesService {
    IRoutesDao routesDao = new RoutesDaoImpl();

    @Override
    public boolean delete(Integer id) {
        boolean delete = routesDao.delete(id);
        return delete;
    }

    @Override
    public Pager pager(int page, int pageSize, TouristRoutes routes) {
        Pager pager = routesDao.pagenate(page,pageSize,routes);
        return pager;
    }

    @Override
    public boolean update(TouristRoutes touristRoutes) {
        boolean updateT = routesDao.update(touristRoutes);
        return updateT;
    }

    @Override
    public boolean save(TouristRoutes routes) {
        if(routes == null){
            System.out.println("user为空");
            return false;
        }

        if(routes.getTouristId() == null){
            return routesDao.insert(routes);
        }else {
            return routesDao.update(routes);
        }
    }

    @Override
    public Pager pagernate(int page, int pageSize, TouristRoutes routes) {
        Pager pager = routesDao.pagenateByCompanyId(page,pageSize,routes);
        return pager;
    }

    @Override
    public TouristRoutes findByRoutesId(Integer touristId) {
        TouristRoutes touristRoutes = routesDao.findByTouristId(touristId);
        return touristRoutes;
    }
}
